/**
 * Anderground project - Subway maps processor application.
 * Copyright (C) 2008-2009 Eldar Abusalimov, Ilya Shurigyn
 * 
 * This file is part of Anderground.
 * 
 * Anderground is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * Anderground is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Anderground.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.anderground.modules.storage;

/**
 * @author Eldar Abusalimov (eldar.abusalimov@gmail.com)
 * @param <IO>
 *            the Object used in I/O operations
 */
public abstract class AbstractIOWrapper<IO> implements IOWrapper<IO> {

	/**
	 * Called just after the I/O Object is opened with {@link #openIO()} method.
	 * <p>
	 * Implementation may override this method to perform some additional
	 * preparations of the I/O Object (for example begin a database
	 * transaction). By default does nothing.
	 * 
	 * @param io
	 *            the Object retrieved from {@link #openIO()}
	 */
	protected void onPreExecute(IO io) {
	}

	/**
	 * Called just after the reading is succeed.
	 * <p>
	 * Implementation may override this method to execute some actions that
	 * should be performed in case of success (for example mark a transaction as
	 * successful). By default does nothing.
	 * 
	 * @param io
	 *            the Object retrieved from {@link #openIO()}
	 */
	protected void onSuccess(IO io) {
	}

	/**
	 * Called just before the IO is closed with {@link #closeIO(Object)}.
	 * <p>
	 * Implementation may override this method to perform some additional
	 * actions over the IO before it will be closed (for example commit a
	 * database transaction). By default does nothing.
	 * 
	 * @param io
	 *            the Object retrieved from {@link #openIO()}
	 */
	protected void onPostExecute(IO io) {
	}

}
